package cn.globalph.housekeeper.ui

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import cn.globalph.housekeeper.Event

open class BaseViewModel :ViewModel(){
    private var _loading = MutableLiveData<Boolean>()
    val loading: LiveData<Boolean> = _loading

    protected var _tokenEvent = MutableLiveData<Event<Boolean>>()
    val tokenEvent:LiveData<Event<Boolean>> = _tokenEvent

    protected var _toastEvent = MutableLiveData<Event<String>>()
    val toastEvent:LiveData<Event<String>> = _toastEvent

    fun setLoading(){
        if(_loading.value == null || _loading.value == false){
            _loading.value = true
        }
    }

    fun setUnLoading(){
        if(_loading.value == null || _loading.value == true){
            _loading.value = false
        }
    }
}